package leecodeHot100.doublePoint;

public class MoveZero {
    public static void main(String[] args) {
        int[] nums = {0,1,0,3,12,5};
        int index = 0;
        //index之前的都是非0，index指向需要交换的0位置
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0) {
                int temp = nums[i];
                nums[i] = nums[index];
                nums[index] = temp;
                index++;
            }
        }
        for (int num : nums) {
            System.out.print(num + " ");
        }
    }
}
